package com.net.TCP04;

import java.io.*;
import java.net.Socket;

/**
 * 客户端
 * 1.创建客户端  必须指定服务器+端口   此时就在连接
 *              Socket（String host,int port）
 *
 * @author jiangbang
 * @date 2016/7/22
 */
public class Client {
    public static void main(String[] args) throws IOException {
        //1、创建客户端，连接上服务器
        Socket client = new Socket("localhost",8888);
        //2、接受从服务器中返回的数据
    /*    BufferedReader br = new BufferedReader(new InputStreamReader(client.getInputStream(),"utf-8"));
        String echo = br.readLine();
        System.out.println(echo);*/
        DataInputStream dis = new DataInputStream(client.getInputStream());
        String msg = dis.readUTF();
        System.out.println(msg);
    }
}
